<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">商户消息列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <?php if (checkPrivilege('notice.message/add')): ?>
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-success"
                                               href="<?= url('notice.message/add') ?>">
                                                <span class="am-icon-plus"></span> 新增
                                            </a>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-9">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <?php $see = $request->get('see') ?: null; ?>
                                        <select name="see"
                                                data-am-selected="{btnSize: 'sm', placeholder: '阅读状态'}">
                                            <option value=""></option>
                                            <option value="-1"
                                                <?= $see === '-1' ? 'selected' : '' ?>>全部
                                            </option>
                                            <option value="0"
                                                <?= $see == 0 ? 'selected' : '' ?>>未读
                                            </option>
                                            <option value="1"
                                                <?= $see == 1 ? 'selected' : '' ?>>已读
                                            </option>
                                        </select>
                                    </div>
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="start_time"
                                               class="am-form-field"
                                               value="<?= $request->get('start_time') ?>" placeholder="请选择起始日期"
                                               data-am-datepicker>
                                    </div>
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="end_time"
                                               class="am-form-field"
                                               value="<?= $request->get('end_time') ?>" placeholder="请选择截止日期"
                                               data-am-datepicker>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="search"
                                                   placeholder="请输入商户名称"
                                                   value="<?= $request->get('search') ?>">

                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>商户名称</th>
                                <th>消息标题</th>
<!--                                <th>消息内容</th>-->
                                <th>是否查看</th>
<!--                                <th>相关信息</th>-->
                                <th>创建时间</th>
                                <th>详情</th>

                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>

                                    <td class="am-text-middle">
                                        <?php if ($item['type']['value'] ==1) : ?>
                                            <span class="x-color-red">全体商户</span>
                                        <?php else: ?>
                                            <?= $item['wxapp']['wxapp_name']; ?>
                                        <?php endif; ?>

                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title"><?= $item['title'] ?></p>
                                    </td>
                                    <td class="am-text-middle">
                                        <?php if ($item['is_see']['value'] ==0) : ?>
                                            <span class="x-color-red">未读</span>
                                        <?php else: ?>
                                            <span class="x-color-green">已读</span>
                                        <?php endif; ?>
                                    </td>
<!--                                    <td class="am-text-middle">--><?//= $item['ext'] ? $item['ext'] :'--' ?><!--</td>-->
                                    <td class="am-text-middle"><?= $item['create_time'] ?></td>

                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if (checkPrivilege('notice.message/edit')): ?>
                                                <a class="tpl-table-black-operation-green"
                                                   href="<?= url('notice.message/edit', ['id' => $item['id']]) ?>">
                                                    编辑</a>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('notice.message/detail')): ?>
                                                <a class="tpl-table-black-operation-red"
                                                   href="<?= url('notice.message/detail', ['id' => $item['id']]) ?>">
                                                    详情</a>
                                            <?php endif; ?>

                                            <?php if (checkPrivilege('notice.message/delete')): ?>
                                                <a href="javascript:void(0);" class="j-delete tpl-table-black-operation-del" data-id="<?= $item['id'] ?>">删除</a>
                                            <?php endif; ?>

                                        </div>
                                    </td>

                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="8" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?></div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        // 删除元素
        var url = "<?= url('notice.message/delete') ?>";
        $('.j-delete').delete('id', url);
    });
</script>

